package fr.afcepf.atod21.expedition.service;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import fr.afcepf.atod21.expedition.business.IExpeditionBusiness;
import fr.afcepf.atod21.expedition.entity.Commande;

@Path("/commande")
public class ExpeditionServiceImpl implements IExpeditionService {
	
	private IExpeditionBusiness businessExpedition;
	
	public void setBusinessExpedition(IExpeditionBusiness businessExpedition) {
		this.businessExpedition = businessExpedition;
	}

	@Path("/addCommande/{commande}/{dateCom}/{adresseFact}/{adresseLivr}")
	@GET
	@Produces(MediaType.TEXT_PLAIN)
	public String addCommande(@PathParam("commande") int idCommande, @PathParam("dateCom") String dateCommande,
			@PathParam("adresseFact") String adresseFacturation, @PathParam("adresseLivr") String adresseLivraison) {
	
		Commande commande = new Commande();
		commande.setAdresseFacturation(adresseFacturation);
		commande.setAdresseLivraison(adresseLivraison);
		commande.setDateCommande(dateCommande);
		commande.setIdCommande(idCommande);
		
	
		
		System.out.println("id de la commande: " + idCommande + ", date de la commande: "+ dateCommande + ", adresse de livraison: " + adresseLivraison +
				", adresse de facturation: " + adresseFacturation);
				
		businessExpedition.addCommande(commande);
		
		
		
		return "Commande enregistrée";
	}
	
	
	
}
